package dao.impl;

import dao.AssistantDao;
import dao.domain.Assistant;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * @author huangzhiyang
 * @Date 2023/11/7
 * @Description
 */
public class AssistantDaoImpl extends BaseDaoImpl implements AssistantDao {
    /**
     * 对象数据储存到数据库
     *
     * @param assistant 操作对象
     */
    @Override
    public void save(Assistant assistant) throws SQLException {
        String sql = "insert into assistant(account, password) values (?, ?)";
        Connection conn = super.getConnection();
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setString(1, assistant.getAccount());
        pstmt.setString(2, assistant.getPassword());
        pstmt.executeUpdate();
        super.closeAll(conn, pstmt, null);
    }
}
